using MicroMsg.Resource.@string;
using MicroMsg.UI.UserContrl;
using MicroMsg.UI.Util;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
namespace MicroMsg.UI.Page
{
	public class ContactSetRemarkView : BasePage
	{
		private DelegateSetRemark mSetRemarkCallBack;
		private SearchAlgorithm searchAlgorithm_0;
		internal Grid LayoutRoot;
		internal panelTitleControl panelTitle;
		internal StackPanel ContentPanel;
		internal TextBlock txtAreaLead;
		internal PhoneTextBox txtInputRemark;
		private bool _contentLoaded;
		public ContactSetRemarkView()
		{
			this.InitializeComponent();
			this.SetAppBarWording();
		}
		protected override void OnPageIn(object[] object_0)
		{
			if (object_0 != null && object_0.Length != 0)
			{
				if (object_0[0] != null && object_0[0] is DelegateSetRemark)
				{
					this.mSetRemarkCallBack = (object_0[0] as DelegateSetRemark);
				}
				if (2 == object_0.Length && object_0[1] != null && object_0[1] is string)
				{
					string text = object_0[1] as string;
					if (!ToolFunction.isEmptyString(text))
					{
						this.txtInputRemark.set_Text(text);
					}
				}
			}
		}
		protected override void OnPageOut()
		{
		}
		private void btnComplete(object sender, EventArgs e)
		{
			if (!string.IsNullOrEmpty(this.txtInputRemark.get_Text()) && !ToolFunction.checkIsLegalRemark(this.txtInputRemark.get_Text()))
			{
				MessageBoxManager.ShowToast(strings.Con_Remark_MsgInvalid, 2500, null, false);
				return;
			}
			if (ToolFunction.getStrDisLen(this.txtInputRemark.get_Text()) > 20)
			{
				MessageBoxManager.ShowToast(string.Format(strings.Con_Remark_MsgTooLong, 10, 20), 2500, null, false);
				return;
			}
			if (this.mSetRemarkCallBack != null)
			{
				this.mSetRemarkCallBack(this.txtInputRemark.get_Text());
				base.GoBack();
			}
		}
		private void btnCancel(object sender, EventArgs e)
		{
			base.GoBack();
		}
		private void txtInputRemark_TextChanged(object sender, TextChangedEventArgs e)
		{
		}
		private void txtInputRemark_KeyDown(object sender, KeyEventArgs e)
		{
			if (e.get_Key() == 3 && sender == this.txtInputRemark)
			{
				e.set_Handled(true);
				this.btnComplete(null, null);
			}
		}
		public void SetAppBarWording()
		{
			if (base.get_ApplicationBar() != null && 1 == base.get_ApplicationBar().get_Buttons().get_Count())
			{
				ApplicationBarIconButton applicationBarIconButton = (ApplicationBarIconButton)base.get_ApplicationBar().get_Buttons().get_Item(0);
				applicationBarIconButton.set_Text(strings.COM_Save);
			}
		}
		[DebuggerNonUserCode]
		public void InitializeComponent()
		{
			if (this._contentLoaded)
			{
				return;
			}
			this._contentLoaded = true;
			Application.LoadComponent(this, new Uri("/MicroMsg;component/Source/UI/Contact/ContactSetRemarkView.xaml", 2));
			this.LayoutRoot = (Grid)base.FindName("LayoutRoot");
			this.panelTitle = (panelTitleControl)base.FindName("panelTitle");
			this.ContentPanel = (StackPanel)base.FindName("ContentPanel");
			this.txtAreaLead = (TextBlock)base.FindName("txtAreaLead");
			this.txtInputRemark = (PhoneTextBox)base.FindName("txtInputRemark");
		}
	}
}
